* Replication code for Aarøe, Petersen and Arceneaux (2017) US Sample 2 *

* This do file reproduces analyses related to the Danish Sample 2
* Use the following replication data set: "Replication Data Set DK Sample 2"
** See the Online Appendix for details on question wording and survey flow

set more off

******************************************************************************************************
* recodings and reliability code reported here
******************************************************************************************************

***********************************************************
*recodings and reliability codes for Test 1
***********************************************************


*Creating scales for contamination disgust, core disgust and animal reminder disgust

* recoding of items for the contamination disgust, core disgust and animal reminder disgust scales
** Note: items 1, 6, and 10 must be reversed; run the code below ONLY ONCE.

*Digust items Haidt scale.
* Note: items 1, 6, and 10 must be reversed; run the code below ONLY ONCE.
ta q1_1
ta q1_6
ta q1_10

gen monkey01 = 4 - q1_1
gen roach06 = 4 - q1_6
gen eye10 = 4 - q1_10

ta monkey01
ta roach06
ta eye10 

recode q1_2 (0=0) (1=1) (2=2) (3=3)(4=4), gen (hand02)
recode q1_3 (0=0) (1=1) (2=2) (3=3)(4=4), gen (throat03)
recode q1_4 (0=0) (1=1) (2=2) (3=3)(4=4), gen (toilet04)
recode q1_5 (0=0) (1=1) (2=2) (3=3)(4=4), gen (grave05)
recode q1_7 (0=0) (1=1) (2=2) (3=3)(4=4), gen (body07)
recode q1_8 (0=0) (1=1) (2=2) (3=3)(4=4), gen (vomit08)
recode q1_9 (0=0) (1=1) (2=2) (3=3)(4=4), gen (cook09)
recode q1_11 (0=0) (1=1) (2=2) (3=3)(4=4), gen (rat11)

recode q1_13 (0=0) (1=1) (2=2) (3=3)(4=4), gen (soup13) 
recode q1_14 (0=0) (1=1) (2=2) (3=3)(4=4), gen (hotel14)
recode q2_1 (0=0) (1=1) (2=2) (3=3)(4=4), gen (maggots15)

recode q2_4 (0=0) (1=1) (2=2) (3=3)(4=4), gen (urine17)
recode q2_5 (0=0) (1=1) (2=2) (3=3)(4=4), gen (soda18)
recode q2_6 (0=0) (1=1) (2=2) (3=3)(4=4), gen (cat19)
recode q2_2 (0=0) (1=1) (2=2) (3=3)(4=4), gen (icecrm20)
recode q2_7 (0=0) (1=1) (2=2) (3=3)(4=4), gen (intest21)
recode q2_8 (0=0) (1=1) (2=2) (3=3)(4=4), gen (underw22)
recode q2_9 (0=0) (1=1) (2=2) (3=3)(4=4), gen (chocl23)
recode q2_10 (0=0) (1=1) (2=2) (3=3)(4=4), gen (ashes24)
recode q2_11 (0=0) (1=1) (2=2) (3=3)(4=4), gen (milk25)
recode q2_12 (0=0) (1=1) (2=2) (3=3)(4=4), gen (condom26)
recode q2_13 (0=0) (1=1) (2=2) (3=3)(4=4), gen (worm27)

*three subscale means (for core disgust, animal-reminder disgust, and contamination-disgust), and the whole scale 

* creation of the core disgust scale 
egen core_av=rmean(monkey01 throat03 roach06 vomit08 rat11 soup13 maggots15 urine17 icecrm20 underw22 milk25 worm27)

* creation of the animal reminder disgust scale
egen anrem_av = rmean(hand02 grave05 body07 eye10 hotel14 cat19 intest21 ashes24)

* creation of the contamination disgust scale
egen contam_av = rmean (toilet04 cook09 soda18 chocl23 condom26)

* creation of the full DS-R scale
egen dsr_av = rmean (monkey01 hand02 throat03 toilet04 grave05 roach06 body07 vomit08 cook09 eye10 rat11 soup13 hotel14 maggots15 urine17 soda18 cat19 icecrm20 intest21 underw22 chocl23 ashes24 milk25 condom26 worm27)

* recoding the core disgust, animal reminder disgust, contamination disgust and the DS-R scales to range form 0 to 1
gen dsr_av01 =dsr_av/4
gen core_av01 =core_av/4
gen anrem_av01 =anrem_av/4
gen contam_av01 =contam_av/4


*Crohnbachs' alpha reliability coefficient for the core disgust scale (reported in Online Appendix A5.1)
alpha monkey01 throat03 roach06 vomit08 rat11 soup13 maggots15 urine17 icecrm20 underw22 milk25 worm27
 
* Crohnbachs' alpha reliability coefficient for the animal reminder disgust scale (reported in Online Appendix A5.1)
alpha hand02 grave05 body07 eye10 hotel14 cat19 intest21 ashes24

* Crohnbachs' alpha reliability coefficient for the contamination disgust scale (reported in the main text in "Materials and methods" in Test 1 and in Online Appendix A4.1.2)
alpha toilet04 cook09 soda18 chocl23 condom26

* mean and standard deviation of the the contamination disgust scale (reported in Online Appedix A4.1.2)
sum contam_av01

* Creation of a contamination disgust scale without the item referencing sexual behavior (for Online Appendix A5.2)
egen contam_nosexual =rmean(toilet04 cook09 soda18 chocl23)
gen contam_nosexual01=(contam_nosexual/4)

* Crohnbachs' alpha reliability coefficient for the DSR-R scale (reported in Online Appendix A5.1)
alpha monkey01 hand02 throat03 toilet04 grave05 roach06 body07 vomit08 cook09 eye10 rat11 soup13 hotel14 maggots15 urine17 soda18 cat19 icecrm20 intest21 underw22 chocl23 ashes24 milk25 condom26 worm27

*creation of the scale measuring opposition to immigration (ranging from 0 to 1)
*NB there is one more item that is reverse scored in the US Sample 1 but NOT here in the Danish sample 2 - this is because of the translation so it is NOT a mistake that q13_3 is not reverse scored
gen q13_1r=q13_1
recode q13_1r (0=6) (1=5) (2=4) (3=3) (4=2) (5=1) (6=0)

gen q13_5r=q13_5
recode q13_5r (0=6) (1=5) (2=4) (3=3) (4=2) (5=1) (6=0)

egen antiim1= rmean(q13_2 q13_3 q13_4 q13_6 q13_1r q13_5r)
ta antiim1
gen antiim=antiim1/6
ta antiim
cor q13_2 q13_3 q13_4 q13_6 q13_1r q13_5r

*Crohnbachs' alpha reliability coefficient for the scale measuring opposition to immigration (reported in the main text in "Materials and methods" in Test 1 and in Online Appendix A4.2)
alpha q13_2 q13_3 q13_4 q13_6 q13_1r q13_5r

* mean and standard deviation of the scale measuring opposition to immigration (reported in Online Appendix A4.2)
sum antiim

* ideology (7-point) ranging from 0 to 1, higher values more right-wing
ta q3
gen ideo=(q3-1)/6
ta ideo

* mean and standard deviation of the 7-point ideology measure (reported in Online Appendix A4.2)
sum ideo

* ideology coded in three categories (for Table A9 in Online Appendix A5.4)
ta q3
gen ideo3=q3
recode ideo3 (1=1) (2=1) (3=1) (4=2) (5=3) (6=3) (7=3)
ta ideo3
label define ideo3 1 "Left-wing (liberals)" 2 "Middle of the road" 3 "right-wing (Conservatives)"
label values ideo3 ideo3

*education ranging from 0 to 1
ta education
* translation of the value labels on the original edcuation variable (As category 2 and 3 are both form of upper secondary school/high school they are coded into the same categeory in the recoding of the education variable)
** 1 "Grund-/folkeskole" (primary and lower secondary school)
** 2 "Almengymnasial uddannelse (studentereksamen/HF)" (General upper secondary education (high school degree/higher preparatory examination))
** 3 "Erhvervsgymnasial uddannelse (HH/HTX og HHX)" (Vocational upper secondary education (higher commercial examination/higher technical examination))
** 4 "Erhvervsfaglig uddannelse" (vocational training)
** 5 "Kort videregående uddannelse under tre år" (short higher education)  
** 6 "Mellemlang videregående uddannelse" (Medium long higher education)
** 7 "Lang videregående uddannelse" (long higher education)
** 8 "Forskeruddannelse (f.eks. PHD)" (PhD)

recode education (1=1) (2=3) (3=3) (4=2) (5=4) (6=5) (7=6) (8=7) (9=.) (else=.), gen (educ)
ta educ

gen education01 =(educ-1)/6
ta education01

*gender (1= female)
gen female=gender
recode female (1=1) (2=0)

*income ranging from 0 to 1
gen income1 =household_income
recode income1 (1=1) (2=2) (3=3) (4=4) (5=5) (6=6) (7=7) (8=8) (9=9) (10=10) (11=11) (else=.)
ta income1
gen income=(income1-1)/10
ta income 

******************************************************************************************************
*Additional recodings for Test 4
******************************************************************************************************

* Measures of approval of contact with immigrants (coded to range from 0 to 1)
** See Online Appendix A11 for coding details and question wording

mvdecode q14_1 q14_2 q14_3 q14_4 q14_5 q14_6 q14_10 q14_11, mv(7)

foreach var of varlist q14_1 q14_2 q14_3 q14_4 q14_5 q14_6 q14_10 q14_11 {
gen `var'_1=`var'/6 
}  
  
label var q14_1_1 "That someone in your immidiate family married an immigrant"
label var q14_2_1 "To have an immigrant family as neighbors"
label var q14_3_1 "To have more immigrants move to your neighborhood"
label var q14_4_1 "To eat a meal prepared by an immigrant"
label var q14_5_1 "To shop in a butcher shop owned by an immigrant"
label var q14_6_1 "To swim in a public swimming pool with many immigrants"
label var q14_10_1 "That immigrants mowed away from the citys other neighborhoods and gathered in their own community"
label var q14_11_1 "That immigrants stopped shopping in your local grocery store and instead only shopped in shops owned by other immigrants"

******************************************************************************************************
* Sample characteristics (reported in the Online Appendix A3.1)
******************************************************************************************************

ta female 
sum ideo
sum age
ta household_income
ta income1

*****************************************************************************************************
* Analyses
*****************************************************************************************************

***********************************************************
* Results for Test 1
***********************************************************

* Results reported in the main text

* Test 1, Table 2, Model 2, main text
eststo: reg antiim contam_av01 female age education01 ideo income
esttab, b(%5.2f) se(%5.2f), using part_2.rtf, replace onecell star(* 0.10 ** 0.02 *** 0.002) wide constant ar2
eststo clear

* Test 1, footnote 6 and Online Appendix A5.4 A5.4, Table A8, Model 2 - interactions between behavioral immune sensitivity and ideology
eststo:  reg antiim c.contam_av01##c.ideo female age education01 income, robust
esttab, b(%5.2f) se(%5.2f), using results_epinion.rtf, replace onecell star(* 0.10 ** 0.020 *** 0.002) label ar2 constant 
eststo clear


* Results reported in the Online Appendix

* Test 1 - Online Appendix A4.1, Table A3, column 2 - bivariate correlations between measures of behavioral immune sensitivity and demographics (two-sided tests)
pwcorr contam_av01 female age education01 income, sig obs

* Test 1 - Online Appendix A5.1, Table A5, Models 3-4, - correlation between contamination disgust and antiimmigration attitudes controling for other types of disgust
reg antiim contam_av01 dsr_av01, beta
reg antiim contam_av01 core_av01 anrem_av01, beta

* Results reported in the Online Appendix A5.2 Supplemental analysis of robustness of the effect of contamination disgust in Table 2 in the main text excluding the item referencing sexual behavior
reg antiim contam_nosexual01 female age education01 ideo income

* Test 1 - Online Appendix A5.4, Table A7, Model 2 - zero-order correlation with ideology
pwcorr ideo contam_av01, sig obs

* Test 1, footnote 6 and Online Appendix A5.4 A5.4, Table A8, Model 2 - interactions between behavioral immune sensitivity and ideology
eststo:  reg antiim c.contam_av01##c.ideo female age education01 income, robust
esttab, b(%5.2f) se(%5.2f), using results_epinion.rtf, replace onecell star(* 0.10 ** 0.020 *** 0.002) label ar2 constant 
eststo clear

* Test 1 - Online Appendix A5.4, Table A9, second row - mean and standard deviation in behavioral immune sensitivity by ideology (3 categories)
bys ideo3: sum contam_av01

* Test 1 - Supplemental analysis reported in text in Online Appendix A5.4 - respondents identifying as right-wing (conservatives) report significantly higher behavioral immune sensitivity than respondents identifying as left-wing (liberals)
reg contam_av01 i.ideo3

******************************************************************
* Results reported for Test 4
******************************************************************

* Results reported in the main text

* Test 4, Figure 2, Effects of Contamination Disgust Sensitivity, Ideology, and Education on Approval of Situations Involving Increased or Decreased Contact with Immigrants
* Note that the published figure was created in Excel on the basis of the results generated by the below analyses
*** Specifically, from each model we entered the unstandardized OLS regression coefficient for the effect of contamination disgust, ideology, income and education into Excel to generate Figure 2
*** In the Excel graph we indicated whether the effect of each of these variables was statistically significant, * p < 0.05, ** p < 0.01, *** p < 0.001, one-sided tests 
 
foreach var of varlist q14_1_1 q14_2_1 q14_3_1 q14_4_1 q14_5_1 q14_6_1 q14_10_1 q14_11_1 {
reg `var' contam_av01 ideo income education01 female age antiim
}
* Results reported in the Online Appendix


* Test 4 - Online Appendix A11, Table A17 - summary statistics for measures of approval of contact situations with immigrants
sum q14_1_1 q14_2_1 q14_3_1 q14_4_1 q14_5_1 q14_6_1 q14_10_1 q14_11_1

* Test 4 - Online Appendix A11, Table A17 - correlation with opposition to immigration scale
cor antiim q14_1_1 q14_2_1 q14_3_1 q14_4_1 q14_5_1 q14_6_1 q14_10_1 q14_11_1 
